package com.zytool.easyrestful.core;

import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.util.Date;

public interface GenericMapper<T extends GenericEntity> extends Mapper<T>, MySqlMapper<T> {

    default int insertEntity(T t) {
        t.setCreateTime(new Date());
        return insert(t);
    }

    default int updateEntity(T t) {
        t.setUpdateTime(new Date());
        return updateByPrimaryKey(t);
    }

}
